package com.abc.core;

import com.abc.core.consts.DataType;
import com.abc.core.consts.OperationFlag;
import com.abc.core.instance.bo.Cell;
import com.abc.core.instance.bo.Inst;
import com.abc.core.instance.bo.Va;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

/**
 * @author lb
 * @date 3/11/22
 */
public class DemoFactory {
    public static Cell createCell() {
        Cell cell = new Cell();
        cell.setDnaCode("cell_dna_code");
        cell.setId(1231L);
        cell.setRootId(4444L);
        cell.setParentId(555L);
        cell.setOperationFlag(OperationFlag.OPERATION_FLAG_DELETE);

        Va va2 = new Va();
        va2.setCode("v2");
        va2.setName("v2name");
        va2.setDataType(DataType.DATA_TYPE_STRING);
        va2.setId(222L);
        va2.setValue("v2Value");

        Va va = new Va();
        va.setCode("v1");
        va.setName("v1name");
        va.setDataType(DataType.DATA_TYPE_STRING);
        va.setId(111L);
        va.setValue("v1Value");
        Map<String, Va> vas = new HashMap<>();
        vas.put(va.getCode(), va);
        vas.put(va2.getCode(), va2);
        cell.setVas(vas);

        Inst inst = new Inst();
        cell.setOwner(inst);


        return cell;
    }

    public static Inst createInst() {
        Inst inst = new Inst();
        inst.setDnaCode("inst_dan_code");
        inst.setDnaName("inst_dan_name");
        inst.setInstType("inst_type");
        inst.setTotal(111);


        Cell cell = DemoFactory.createCell();
        cell.setOwner(inst);

        Cell cell2 = DemoFactory.createCell();
        cell2.setOwner(inst);


        inst.setCells(Arrays.asList(cell, cell2));
        return inst;
    }
}
